local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__New = ____lualib.__TS__New
local __TS__SourceMapTraceBack = ____lualib.__TS__SourceMapTraceBack
__TS__SourceMapTraceBack(debug.getinfo(1).short_src, {["9"] = 1,["10"] = 1,["11"] = 7,["12"] = 7,["13"] = 7,["14"] = 9,["15"] = 10,["16"] = 9,["21"] = 17,["25"] = 25,["26"] = 26,["27"] = 26,["28"] = 26,["29"] = 26,["30"] = 26,["31"] = 26,["32"] = 26,["33"] = 26,["34"] = 26,["35"] = 26,["36"] = 25,["37"] = 34,["39"] = 35,["40"] = 35,["41"] = 36,["42"] = 37,["43"] = 37,["44"] = 37,["45"] = 38,["46"] = 37,["47"] = 37,["48"] = 40,["49"] = 41,["52"] = 35,["55"] = 34,["56"] = 51,["57"] = 52,["59"] = 53,["60"] = 53,["61"] = 54,["62"] = 55,["63"] = 55,["64"] = 55,["65"] = 56,["66"] = 55,["67"] = 55,["68"] = 58,["69"] = 53,["72"] = 60,["73"] = 51,["74"] = 67,["75"] = 68,["76"] = 69,["77"] = 70,["78"] = 70,["79"] = 70,["80"] = 70,["81"] = 71,["82"] = 67});
local ____exports = {}
local ____list = require("kernel.util.list")
local KList = ____list.default
____exports.default = __TS__Class()
local KTable = ____exports.default
KTable.name = "KTable"
function KTable.prototype.____constructor(self, name)
    self.handle = gameapi.get_table(name)
end
__TS__SetDescriptor(
    KTable.prototype,
    "size",
    {get = function(self)
        return gameapi.get_table_length(self.handle)
    end},
    true
)
function KTable.prototype.get(self, keys, defaultValue)
    return gameapi.get_table_var(
        self.handle,
        keys[1],
        keys[2],
        keys[3],
        keys[4],
        keys[5],
        defaultValue,
        ""
    )
end
function KTable.prototype.each(self, keys, callback)
    do
        local i = 1
        while i <= self.size do
            local value = {}
            __TS__ArrayForEach(
                keys,
                function(____, key)
                    value[key] = self:get({i, key})
                end
            )
            local val = callback(nil, value)
            if val == false then
                break
            end
            i = i + 1
        end
    end
end
function KTable.prototype.toArray(self, keys)
    local result = {}
    do
        local i = 1
        while i <= self.size do
            local value = {}
            __TS__ArrayForEach(
                keys,
                function(____, key)
                    value[key] = self:get({i, key})
                end
            )
            result[#result + 1] = value
            i = i + 1
        end
    end
    return result
end
function KTable.prototype.toList(self, keys)
    local result = self:toArray(keys)
    local list = __TS__New(KList)
    __TS__ArrayForEach(
        result,
        function(____, item) return list:push(item) end
    )
    return list
end
return ____exports
